home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / plnk081.zip / pilot-link.0.8.1 / Perl5 / test.pl < prev    next >
Text File  |  1997-08-08  |  2KB  |  125 lines

  1. sub FooBar { print "Foo: $_[0]\n"; $x = $_[0]; $x =~ s/[aeiou]/\U$&/g; return $x };
  2.  
  3. use PDA::Pilot;
  4. use Data::Dumper;
  5.  
  6. if ($ARGV[0]) {
  7.     $port = $ARGV[0];
  8. } else {
  9.     print "What port should I use [/dev/cua3]: ";
  10.     $port = <STDIN>;
  11.     chop $port;
  12.     $port ||= "/dev/cua3";
  13. }
  14.  
  15. $socket = PDA::Pilot::openPort($port);
  16.  
  17. # OpenPort is the equivalent of
  18. #
  19. #$socket = PDA::Pilot::socket(PI_AF_SLP, PI_SOCK_STREAM, PI_PF_PADP);
  20. #
  21. #PDA::Pilot::bind($socket,
  22. #    {family => PI_AF_SLP, device => $port});
  23. #
  24. #PDA::Pilot::listen($socket, 1);
  25.  
  26. print "Now press the HotSync button\n";
  27.  
  28. $dlp = PDA::Pilot::accept($socket);
  29.  
  30. $PDA::Pilot::UnpackPref{mail}->{3} = sub { $_[0] . "x"};
  31.  
  32. @pref = $dlp->getPref('mail', 3);
  33.  
  34. @pref = "Not available" if not defined $pref[0];
  35.  
  36. print "Mail preferences: @pref\n";
  37.  
  38. $ui = $dlp->getUserInfo;
  39.  
  40. @b = $dlp->getBattery;
  41.  
  42. $i = $dlp->getDBInfo(0);
  43.  
  44. print Dumper($i);
  45.  
  46. print "Battery voltage is $b[0], (warning marker $b[1], critical marker $b[2])\n";
  47.  
  48. $dlp->tickle;
  49.  
  50. $db = $dlp->open("MemoDB");
  51.  
  52. print "db class is ", ref $db, "\n";
  53.  
  54. $r = $db->getRecord(0);
  55.  
  56. print "Contents: '$r->{text}'\n";
  57.  
  58. $app = $db->getAppBlock;
  59.  
  60. print Dumper($app);
  61.  
  62. print "Categories: @{$app->{categoryName}}\n";
  63.  
  64. print Dumper($db->getPref(0));
  65. print Dumper($db->getPref(1));
  66.  
  67. $db->close();
  68.  
  69. $db = $dlp->open("DatebookDB");
  70.  
  71. print "db class is ", ref $db, "\n";
  72.  
  73. $r = $db->getRecord(0);
  74.  
  75. print "Contents: ", Dumper($r);
  76.  
  77. $app = $db->getAppBlock;
  78.  
  79. print Dumper($app);
  80.  
  81. print "Categories: @{$app->{categoryName}}\n";
  82.  
  83. $db->close();
  84.  
  85. $db = $dlp->open("MailDB");
  86.  
  87. if ($db) {
  88.  
  89.     print "db class is ", ref $db, "\n";
  90.     
  91.     $r = $db->getRecord(0);
  92.  
  93.     print "Contents: ", Dumper($r);
  94.     
  95.     $app = $db->getAppBlock;
  96.     
  97.     print Dumper($app);
  98.     
  99.     print "Categories: @{$app->{categoryName}}\n";
  100.     
  101.     $db->close();
  102. }
  103.  
  104. $db = $dlp->open("ExpenseDB");
  105. if ($db) {
  106.     
  107.     print "db class is ", ref $db, "\n";
  108.     
  109.     $r = $db->getRecord(0);
  110.     
  111.     print "Contents: ", Dumper($r);
  112.     
  113.     $app = $db->getAppBlock;
  114.     
  115.     print Dumper($app);
  116.     
  117.     print "Categories: @{$app->{categoryName}}\n";
  118. }
  119.  
  120. undef $db; # Close database
  121.  
  122. undef $dlp; # Close connection
  123.  
  124. print "Your name is $ui->{name}\n";
  125.